/********************************
 * @FileName:     SessionContext.java
 * @Description:  SessionContext.java -
 * @Copyright:    Copyright(C) 2010-2011 mbool.com
 * @Company       MBOOL-TEAM zhangjiayi LTD.
 * @author:       zhangjiayi
 * @version       V1.0 
 * @Createdate:   2016-5-11 下午9:52:51
 *
 * All rights Reserved, Designed By MBOOL-TEAM
 *
 * Modification  History:
 * Date         Author        Version        Discription
 * -----------------------------------------------------------------------------------
 * 2016-5-11       zhang       1.0         TODO
 * Why & What is modified: <修改原因描述>
 *
 ********************************/
package com.rowline.admin.module.util.context;

import com.rowline.admin.module.util.domain.User;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;


/**
 * @ClassName: SessionContext
 * @Description: 会话的内容和上下文
 * @author: zhangjiayi
 * @date: 2016-5-11 下午9:52:51
 * 
 */
public class SessionContext {

	static Logger log = LoggerFactory.getLogger(SessionContext.class);

	static Boolean SESSION_PERSISTENCE = null; 
	/**
	 * @Title:       
	 * @Description: 
	 * @throws: 
	 * @return
	 * @date:	     2016-7-20 上午12:09:58
	 *
	 */
	private static boolean isRedisCache(){
		
		return false;
	}
	
	/**
	 * 添加session
	 */
	public static void setSession(String key, Object value) {
		if(isRedisCache()) {
		//	RedisSessionContext.setSession(key, value);
		}else{
			HttpSessionContext.setSession(key, value);
		}
		
	}

	/**
	 * 获取当前session
	 */
	public static Object getSession(String key) {
		if(isRedisCache()) {
			return null;
		}else{
			return HttpSessionContext.getSession(key);
		}
	}

	/**
	 * 当前登录用户员
	 */
	public static User getCurrentUser() {
		if(isRedisCache()) {
			return null;
		}else{
			return HttpSessionContext.getCurrentUser();
		}
	}

	/**
	 * @Title: 登录用户名
	 * @Description:
	 * @throws:
	 * @return
	 * @date: 2016-5-21 下午11:50:32
	 * 
	 */
	public static String getCurrentUserName() {
		if(isRedisCache()) {
			return null;
		}else{
			return HttpSessionContext.getCurrentUserName();
		}
	}

	/**
	 * @Title: 设置当前登录用户
	 * @Description:
	 * @throws:
	 * @param user
	 * @date: 2016-5-21 下午11:47:11
	 * 
	 */
	public static void setCurrentUser(User user) {
		if(isRedisCache()) {
		//	RedisSessionContext.setCurrentUser(user);
		}else{
			HttpSessionContext.setCurrentUser(user);
		}
	}

	public static void remove(String key) {
		if(isRedisCache()) {
		//	RedisSessionContext.remove(key);
		}else{
			HttpSessionContext.remove(key);
		}
	}

}
